﻿
//获取浏览器参数
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}


/*窗体加载*/
$(function () {
    //使焦点在当前页面
    window.focus();
});

//主页面快捷键
$(document).on('keydown', function (e) {
    switch (e.keyCode) {
        case 27:        //ESC
            e.preventDefault();
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.layer.close(index);
            parent.$('#sku').focus();
            break;
        case 97:   //1 重打小票
            e.preventDefault();
            other('smallticket.html?t=1', '400px', '300px');
            break;
        case 98:   //2 退款模式
            e.preventDefault();
            var  id = getQueryString("id");
            var sysname = decodeURI(decodeURI(getQueryString("name")));
            sysname = encodeURI(encodeURI(sysname));

            parent.window.location.href = "returngoods.html?id=" + id + "&name=" + sysname;
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.layer.close(index);
            break;
        case 99:   //3 收银交班
            e.preventDefault();
            var index = parent.top.layer.getFrameIndex(window.name); //获取窗口索引
            parent.top.layer.close(index);
            parent.top.parent.message('transfer.html', '700px', '500px');
            break;
        case 100:   //4 会员开卡
            e.preventDefault();
            message('newmember.html?t=2', '400px', '400px');
            break;
    }
})